package com.bwie.controller;

import com.bwie.pojo.TbProd;
import com.bwie.service.TbProdService;
import com.bwie.utils.Result;
import com.bwie.vo.AttaVo;
import com.bwie.vo.ProdPageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2025/5/26 16:51
 */

@RestController
@RequestMapping("/shop/prod")
public class TbProdController {

    @Autowired
    TbProdService tbProdService;

    /**
     * @description 分页获取商品列表
     * @params []
     * @return com.bwie.utils.Result
     * @author 军哥
     * @date 2025/5/26 16:52
     */
    @PostMapping("/getProdList")
    public Result getProdList(@RequestBody ProdPageVo prodPageVo) {
        return tbProdService.getProdList(prodPageVo);
    }

    /**
     * @description 添加商品
     * @params [tbProd]
     * @return com.bwie.utils.Result
     * @author 军哥
     * @date 2025/5/27 10:19
     */
    @PostMapping("/addProd")
    public Result addProd(@RequestBody @Validated TbProd tbProd) {
        return tbProdService.addProd(tbProd);
    }

    /**
     * @description 批量删除商品
     * @params [prodList]
     * @return com.bwie.utils.Result
     * @author 军哥
     * @date 2025/5/27 14:54
     */
    @PostMapping("/deleteProdAll")
    public Result deleteProdAll(@RequestBody List<TbProd> prodList) {
        return tbProdService.deleteProdAll(prodList);
    }

    /**
     * @description 添加商品附件
     * @params []
     * @return com.bwie.utils.Result
     * @author 军哥
     * @date 2025/5/28 16:20
     */
    @PostMapping("/addProdAtta")
    public Result addProdAtta(@RequestBody AttaVo attaVo) {
        return tbProdService.addProdAtta(attaVo);
    }

}
